<template>
  <div class="home-page">
    <!-- 用户信息部分 -->
    <div class="user-info">
      <div class="user-info-avatar">
        <img :src="userStore.userInfo.avatar" title="头像" alt="头像">
      </div>
      <div class="user-info-tip">
        <p class="info">{{showTime()}},<span>{{userStore.userInfo.name}}</span></p>
        <p class="title">硅谷甄选运营平台</p>
      </div>
    </div>
    <!-- svg图片欢迎部分 -->
    <div class="svg-icon">
      <svg-icon iconName="welcome" width="500px" height="300px"></svg-icon>
    </div>
  </div>
</template>

<script setup lang="ts">
import { onMounted } from "vue";
//@ts-ignore
import useUserStore from "@/store/user.ts";
const userStore = useUserStore();

onMounted(()=>{
  //获取用户信息,路由前置守卫处每次会请求用户信息，此处就不用了
  userStore.getUserInfo();
})
//获取时间状态
function showTime():string{
  let msg:string = '';
  let hours:number = new Date().getHours();
  let minutes:number = new Date().getMinutes();
  if(hours > 0 && (hours < 5 || (hours == 5 && minutes <= 30))){
    msg = "夜深了";
  }else if((hours > 5 || (hours == 5 && minutes > 30)) && hours < 12){
    msg = "上午好";
  }else if(hours >= 12 && (hours < 18 || (hours == 18 && minutes <= 30))){
    msg = "下午好";
  }else if((hours > 18 || (hours == 18 && minutes > 30)) && (hours < 23 || (hours == 23 && minutes <= 30))){
    msg = "晚上好";
  }else if(hours == 23 && minutes > 30){
    msg = "夜深了";
  }
  return msg;
}
</script>

<style lang="scss">
.home-page{
  //用户信息部分
  .user-info{
    width:100%;
    height: 25vh;
    box-shadow: 2px 2px 15px #708ecf;
    display: flex;
    justify-content: center;
    align-items: center;

    .user-info-avatar{
      width: 15vh;
      height: 15vh;
      border-radius: 50%;
      margin: 30px;

      img{
        width: 15vh;
        height: 15vh;
        border-radius: 50%;
      }
    }
    .user-info-tip{
      width: 100%;
      height: 100%;

      p{
        margin: 7vh 0;
        cursor: pointer;
        span{
          color:blue;
        }
        &.title{
          font-family:'Courier New', Courier, monospace;
          font-size:16px;
        }
        &.info{
          font-size: 20px;
          font-weight: bold;
        }
      }
    }
  }
  //svg图片部分
  .svg-icon{
    width:100%;
    height: 50vh;
    display: flex;
    justify-content: center;
    align-items:center;
  }
}

</style>